//-------------------------------------------------------------------
// CVORegistry header file
//-------------------------------------------------------------------
//
// Copyright ?000 Virtual Office Systems Incorporated
// All Rights Reserved
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included.
//
// This code can be compiled, modified and distributed freely, providing
// that this copyright information remains intact in the distribution.
//
// This code may be compiled in original or modified form in any private
// or commercial application.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage, in any form, caused
// by this code. Use it at your own risk.
//-------------------------------------------------------------------

#pragma once

#include "VOString.h"

enum ValueType
{
	typeError = 0,
	typeBinary,
	typeDWORD,
	typeString,
	typeStringList
};

#define DEFAULT_DWORD 0xDEF0

class CVORegistry
{
public:
	CVORegistry(HKEY hkeyParent, LPCTSTR pcszSubkey, BOOL fCreateIfNew = TRUE);
	CVORegistry(const CVORegistry& rSrc);	// Default Copy Constructor
	virtual ~CVORegistry();

	DWORD GetValueSize(LPCTSTR pcszValueName);
	BOOL Close();
	BOOL DeleteSubkey(LPCTSTR pcszSubkey);
	BOOL DeleteValue(LPCTSTR pcszValueName);
	DWORD GetDisposition() const;
	BOOL GetFirstSubkey(CVOString& strSubkey);
	BOOL GetFirstValue(CVOString &strValueName);
	BOOL GetNextSubkey(CVOString& strSubkey);
	BOOL GetNextValue(CVOString &strValueName);
	BOOL GetSubkey(CVOString& strSubkey, int nOffset);
	BOOL ReadBinary(LPCTSTR pcszKey, LPBYTE pData, DWORD dwBufferSize);
	BOOL ReadBinary(LPCTSTR pcszKey, LPBYTE pData, LPDWORD lpcbData);
	DWORD ReadDWORD(LPCTSTR pcszKey, DWORD dwDefault = DEFAULT_DWORD);
	CVOString ReadString(LPCTSTR pcszKey, LPCTSTR pcszDefault = NULL);
	BOOL SubkeyExists(LPCTSTR pcszSubkey);
	BOOL ValueExists(LPCTSTR pcszValueName);
	BOOL WriteBinary(LPCTSTR pcszKey, LPBYTE pData, DWORD cbData);
	BOOL WriteDWORD(LPCTSTR pcszKey, DWORD dwValue);
	BOOL WriteString(LPCTSTR pcszKey, LPCTSTR pcszValue);
	enum ValueType GetValueType(LPCTSTR pcszValueName);
	operator HKEY();
	operator HKEY*();
	operator LPCTSTR() const;

protected:
	HKEY m_hkey;
	DWORD m_dwDisposition;
	int m_nSubkeyIndex;
	CVOString m_strSubkey;
};

